package com.haohope.framework.wb.lock;

import java.util.concurrent.TimeUnit;
import org.redisson.api.RLock;
import org.redisson.api.RedissonClient;

import com.haohope.framework.lock.ILock;

public class RedissionVarLock implements ILock{
	private RLock lock = null;
	public RedissionVarLock(RedissonClient redissonClient) {
		this.lock = redissonClient.getLock("haohope:lock:var");
	}
	@Override
	public void lock() {
		lock.lock();
	}

	@Override
	public void lockInterruptibly() throws InterruptedException {
		lock.lockInterruptibly();
	}

	@Override
	public boolean tryLock() {
		return lock.tryLock();
	}

	@Override
	public boolean tryLock(long time, TimeUnit unit) throws InterruptedException {
		return lock.tryLock(time, unit);
	}

	@Override
	public void unlock() {
		lock.unlock();
	}

}
